class BookTagLib { def parent = { attrs, body -> pageScope.parent = "John" } def child = { attrs, body -> out << "My parent is ${pageScope.parent}" } }
<g:parent> <g:child /> // Outputs "My parent is John" </g:parent>
pageScope
变量包含一个基础的model,被页面熟练操作. 也可以把变量从父标签传递给子标签..